package com.ruoyi.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 创建时间、更新时间新增过滤
 */
@Component
public class CommonMetaObjectHandler implements MetaObjectHandler {
    /**
     * @apiNote 新增
     */
    @Override
    public void insertFill(MetaObject metaObject) {

        this.strictInsertFill(metaObject,"createTime", Date.class,new Date());
        this.strictInsertFill(metaObject,"updateTime",Date.class,new Date());
    }

    /**
     * @apiNote 修改
     */
    @Override
    public void updateFill(MetaObject metaObject) {

        this.strictInsertFill(metaObject,"updateTime",Date.class,new Date());
    }
}
